package com.cyf.filmDownload.m3u8.core;

import com.cyf.filmDownload.common.util.UrlUtil;
import com.cyf.filmDownload.okhttp.HttpUtil;
import lombok.extern.slf4j.Slf4j;
import okhttp3.Response;
import okhttp3.ResponseBody;
import org.apache.commons.lang3.StringUtils;

import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;


@Slf4j
public enum M3u8UrlStrategy {

    PARENT_PATH {
        @Override
        public String generateUrl(String firstM3u8Url, String secondM3u8Uri) {
            return firstM3u8Url.substring(0, firstM3u8Url.lastIndexOf("/")) + "/" + secondM3u8Uri;
        }
    },
    DOMAIN_PATH {
        @Override
        public String generateUrl(String firstM3u8Url, String secondM3u8Uri) {
            return UrlUtil.extractBaseURL(firstM3u8Url) + "/" + secondM3u8Uri;
        }
    };

    abstract String generateUrl(String firstM3u8Url, String secondM3u8Uri);

}
